\documentclass[twoside,11pt,openany]{book}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}

% Fix copy/pasting of ligatures in Acrobat
\input{glyphtounicode.tex}
\pdfgentounicode=1 %

\input{preamble}

% All registers are named here. That way when we rename one we'll get errors if
% there are still references to the old name.

\usepackage{makeidx}
\makeindex

\usepackage{xspace}
\newcommand{\defregname}[2]{\providecommand{#1}{{\tt #2}\xspace}}
\newcommand{\deffieldname}[2]{\providecommand{#1}{{$|#2|$}\xspace}}
\deffieldname{\FcsrMcontrolMprv}{MPRV}
\deffieldname{\FcsrMcontrolMie}{MIE}
\deffieldname{\Fmxl}{MXL}
\defregname{\Rmisa}{misa}
\defregname{\Rmstatus}{mstatus}
\defregname{\Rmcause}{mcause}
\defregname{\Rmie}{mie}

\deffieldname{\Fasid}{ASID}
\defregname{\Rsatp}{satp}

\defregname{\Azero}{a0}
\defregname{\Aone}{a1}

\defregname{\Rzero}{zero}
\defregname{\Szero}{s0}
\defregname{\Sone}{s1}

\defregname{\Tzero}{t0}

\defregname{\Xzero}{x0}
\defregname{\Xone}{x1}
\defregname{\Xeight}{x8}
\defregname{\Xnine}{x9}
\defregname{\Xten}{x10}
\defregname{\Xeleven}{x11}
\defregname{\Xthirtyone}{x31}
\defregname{\Fone}{f1}
\defregname{\Rpc}{pc}
\defregname{\Rmhartid}{mhartid}
\defregname{\Rmepc}{mepc}
\defregname{\Rdataone}{data1}

\input{hwbp_registers.tex.inc}
\input{core_registers.tex.inc}
\input{jtag_registers.tex.inc}
\input{dm_registers.tex.inc}
\input{sample_registers.tex.inc}
\input{abstract_commands.tex.inc}
\input{sw_registers.tex.inc}

\deffieldname{\Fhartsel}{\hyperref[hartsel]{hartsel}}
\deffieldname{\Fsize}{\hyperref[sizelo]{size}}
\deffieldname{\Faction}{action}
\deffieldname{\Fresethaltreq}{\hyperref[resethaltreq]{resethaltreq}}

\input{vc.tex}

\newcommand{\versionnum}{0.14.0\ifrelease\else-DRAFT\fi}

\begin{document}

\title{RISC-V External Debug Support\\
Version \versionnum\\
\GITHash
}
\author{Editors: \\
Ernie Edgar \textless ernie.edgar@sifive.com\textgreater, SiFive, Inc. \\
Tim Newsome \textless tim@sifive.com\textgreater, SiFive, Inc.}
\date{\GITAuthorDate}
\maketitle

Contributors to all versions of the spec in alphabetical order (please contact
editors to suggest corrections):
Bruce Ableidinger,
Krste Asanovi\'{c},
Peter Ashenden,
Allen Baum,
Mark Beal,
Alex Bradbury,
Chuanhua Chang,
Zhong-Ho Chen,
Monte Dalrymple,
Paul Donahue,
Vyacheslav Dyachenko,
Peter Egold,
Marc Gauthier,
Markus Goehrle,
Robert Golla,
John Hauser,
Richard Herveille,
Yung-ching Hsiao,
Po-wei Huang,
Scott Johnson,
Grigorios Magklis,
Jean-Luc Nagel,
Aram Nahidipour,
Rishiyur Nikhil,
Gajinder Panesar,
Deepak Panwar,
Antony Pavlov,
Klaus Kruse Pedersen,
Ken Pettit,
Joe Rahmeh,
Gavin Stark,
Wesley Terpstra,
Megan Wachs,
Jan-Willem van de Waerdt,
Stefan Wallentowitz,
Ray Van De Walker,
Andrew Waterman,
Andy Wright,
and Bryan Wyatt.

\markboth{RISC-V External Debug Support Version \versionnum}
{RISC-V External Debug Support Version \versionnum}
\thispagestyle{empty}

\frontmatter

\input{preface.tex}

\tableofcontents
\listoffigures
\listoftables

\mainmatter

\newpage

\input{introduction}
\input{overview}
\input{debug_module}
\input{core_debug}
\input{trigger}
\input{dtm}

\newpage
\appendix

\include{implementations}
\include{debugger_implementation}

\clearpage
\addcontentsline{toc}{chapter}{Index}
\label{index}
\printindex

\ifrelease
\else
    \chapter{Change Log}

    \begin{versionhistory}
        \input{changelog.tex}
    \end{versionhistory}
\fi

\end{document}
